package com.ruoyi.psi.purchase.storage.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;

/**
 * 采购入库
 * psi_purchase_storage
 */
public class PurchaseStorage extends BaseEntity {
    /**
     * 采购订单入库编号
     */
    @NotNull(message = "采购订单入库编号不能为空")
    @ApiModelProperty(value = "采购付款", required = true)
    private String purchaseStorageId;
    /**
     * 采购订单编号
     */
    @NotNull(message = "采购订单编号不能为空")
    @ApiModelProperty(value = "采购付款", required = true)
    private String purchaseOrderId;
    /**
     * 仓库编号
     */
    @NotNull(message = "仓库编号不能为空")
    @ApiModelProperty(value = "采购付款", required = true)
    private String warehouseId;
    /**
     * 仓库名称
     */
    @ApiModelProperty("仓库名称")
    @Excel(name = "仓库名称")
    private String warehouseName;
    /**
     * 供应商编号
     */
    @ApiModelProperty("供应商编号")
    private String supplierInfoId;
    /**
     * 供应商名称
     */
    @ApiModelProperty("供应商名称")
    private String supplierInfoName;
    /**
     * 入库数量
     */
    @ApiModelProperty("入库数量")
    private double purchaseStorageNumber;
    /**
     * 入库金额
     */
    @ApiModelProperty("入库金额")
    private double purchaseStoragePrice;
    /**
     * 入库时间
     */
    @ApiModelProperty("入库时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Timestamp createTime;
    /**
     * 备注
     */
    @ApiModelProperty("备注")
    private String remark;
    /**
     * 采购入库详细
     */
    private List<PurchaseStorageList>purchaseStorageLists;

    public List<PurchaseStorageList> getPurchaseStorageLists() {
        return purchaseStorageLists;
    }

    public void setPurchaseStorageLists(List<PurchaseStorageList> purchaseStorageLists) {
        BigDecimal psn = new BigDecimal("0");//purchaseStorageNumber入库数量
        BigDecimal psp = new BigDecimal("0");//purchaseStoragePrice入库金额
        for (int i = 0; i < purchaseStorageLists.size(); i++) {
            psn = psn.add(BigDecimal.valueOf(purchaseStorageLists.get(i).getPurchaseStorageNumber()));
            psp = psp.add(BigDecimal.valueOf(purchaseStorageLists.get(i).getPurchaseStoragePrice()));
        }
        setPurchaseStorageNumber(psn.doubleValue());
        setPurchaseStoragePrice(psp.doubleValue());
        this.purchaseStorageLists = purchaseStorageLists;
    }

    public String getPurchaseStorageId() {
        return purchaseStorageId;
    }

    public void setPurchaseStorageId(String purchaseStorageId) {
        this.purchaseStorageId = purchaseStorageId;
    }

    public String getPurchaseOrderId() {
        return purchaseOrderId;
    }

    public void setPurchaseOrderId(String purchaseOrderId) {
        this.purchaseOrderId = purchaseOrderId;
    }

    public String getWarehouseId() {
        return warehouseId;
    }

    public void setWarehouseId(String warehouseId) {
        this.warehouseId = warehouseId;
    }

    public String getWarehouseName() {
        return warehouseName;
    }

    public void setWarehouseName(String warehouseName) {
        this.warehouseName = warehouseName;
    }

    public String getSupplierInfoId() {
        return supplierInfoId;
    }

    public void setSupplierInfoId(String supplierInfoId) {
        this.supplierInfoId = supplierInfoId;
    }

    public String getSupplierInfoName() {
        return supplierInfoName;
    }

    public void setSupplierInfoName(String supplierInfoName) {
        this.supplierInfoName = supplierInfoName;
    }

    public double getPurchaseStorageNumber() {
        return purchaseStorageNumber;
    }

    public void setPurchaseStorageNumber(double purchaseStorageNumber) {
        this.purchaseStorageNumber = purchaseStorageNumber;
    }

    public double getPurchaseStoragePrice() {
        return purchaseStoragePrice;
    }

    public void setPurchaseStoragePrice(double purchaseStoragePrice) {
        this.purchaseStoragePrice = purchaseStoragePrice;
    }

    @Override
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Override
    public String getRemark() {
        return remark;
    }

    @Override
    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Override
    public String toString() {
        return "PurchaseStorage{" +
                "purchaseStorageId='" + purchaseStorageId + '\'' +
                ", purchaseOrderId='" + purchaseOrderId + '\'' +
                ", warehouseId='" + warehouseId + '\'' +
                ", warehouseName='" + warehouseName + '\'' +
                ", supplierInfoId='" + supplierInfoId + '\'' +
                ", supplierInfoName='" + supplierInfoName + '\'' +
                ", purchaseStorageNumber=" + purchaseStorageNumber +
                ", purchaseStoragePrice=" + purchaseStoragePrice +
                ", createTime=" + createTime +
                ", remark='" + remark + '\'' +
                ", purchaseStorageLists=" + purchaseStorageLists +
                '}';
    }
}
